//app.js

App({
  data: {
    Url : '',
    list: '',
    userName:'',
    avatarUrl:'',
    bid    :'',
    address: {
      name : '',
      id   : ''
    },
    isboss:false,
    value :"",
    set   :null,
  }, 
  WxParse : require('/wxParse/wxParse.js'),
  url:'https://lcar.4hl.cn/api',
  uploadUrl:'https://lcar.4hl.cn',
  onLaunch: function () {
   var that=this;
    if(!wx.getStorageSync('uid') || !wx.getStorageSync('openid')){
      wx.login({
        success: res => {
          wx.request({
            url: that.url + '/user/login',
            data: {
              code: res.code
            },
            method: 'post',
            success: function (res) {
              if (res.data.code == 1) {
                wx.setStorageSync('openid', res.data.data.openid);
                wx.setStorageSync('uid', res.data.data.uid);
                wx.request({
                  url: that.url + '/Business/my_defaults',
                  method: 'post',
                  data: {
                    uid: res.data.data.uid
                  },
                  success: function (e) {
                    if (e.data.code == 1) {
                      wx.setStorageSync('bid', e.data.data.bid)
                    }
                  }
                })
              } else {
                wx.showToast({
                  title: res.data.msg,
                  icon: 'none'
                })
              }
            }
          })
        }
      })
    }
  }, 
  globalData: {
    userInfo: null
  }
})